require 'dbi'

class SqlExec
  attr_accessor:host,:db,:uid,:pwd,:constr
  def initialize(host, db, uid, pwd)
    @host = host
    @db = db
    @uid = uid
    @pwd = pwd
    @constr = "DBI:ADO:Provider=SQLOLEDB; Data Source=#{host}; Initial Catalog=#{db}; User Id=#{uid}; Password=#{pwd}"
  end
  def ddlquery(query)
    @dbh = DBI.connect(@constr)
    @dbh.do(query)
    @dbh.commit
  end
  def selquery(query)
    @dbh = DBI.connect(@constr)
    @dbh.select_all(query)
  end
end
